package com.dunshan.dunshanlogback.controller;

import com.dunshan.dunshanlogback.pojo.Result;
import com.dunshan.dunshanlogback.pojo.UserInfo;
import lombok.extern.log4j.Log4j2;
import org.slf4j.MDC;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;

/**
 * @author .dunshan
 * @program: dunshan-pef
 * @description: tread
 * @date 2021-09-29 10:52:13
 */
@Log4j2
@Controller
public class IndexController {

    @GetMapping({"/"})
    @ResponseBody
    public Result indexPage(Integer id) {
        HashMap<String, Object> map = new HashMap<>();
        UserInfo userInfo = new UserInfo();
        userInfo.setName("112");
        userInfo.setPwd("wewe");
        UserInfo userInfo1 = new UserInfo();
        userInfo1.setName("1ewwe12");
        userInfo1.setPwd("wewrere");

        ArrayList<UserInfo> list = new ArrayList<>();
        list.add(userInfo);
        list.add(userInfo1);
        map.put("rws", list);
        map.put("id", id);

        return Result.buildSuccess(map);
    }

    @GetMapping({"/index/{id}"})
    @ResponseBody
    public Result indexPageInex(@PathVariable Integer id) {

//        if (id != 0) {
//            MDC.put("traceId", "23232");
//        }
        HashMap<String, Object> map = new HashMap<>();
        UserInfo userInfo = new UserInfo();
        userInfo.setName("112");
        userInfo.setPwd("wewe");
        UserInfo userInfo1 = new UserInfo();
        userInfo1.setName("1ewwe12");
        userInfo1.setPwd("wewrere");

        ArrayList<UserInfo> list = new ArrayList<>();
        list.add(userInfo);
        list.add(userInfo1);
        map.put("rws", list);
        map.put("id", id);

        return Result.buildSuccess(map);
    }

}
